package com.baizhi.config;

import com.baizhi.webservice.UserWebService;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class CXFConfig {

    @Autowired
    private Bus bus;
    @Autowired
    private UserWebService userWebService;

    /*相当于以前的 Web.xml代理 Webservice服务*/
    @Bean
    public ServletRegistrationBean cxfservlet(){
        return new ServletRegistrationBean(new CXFServlet(),"/cxf/*");
    }

    /*服务注册*/
    @Bean
    public Endpoint userEndpoint(){
        EndpointImpl endpoint = new EndpointImpl(bus,userWebService);
        endpoint.publish("/wb");
        return endpoint;
    }

}
